<%@ page language="java" contentType="text/html;charset=utf-8" pageEncoding="utf-8" %>
<%@ page import="java.util.*" %>
<%@ page import="com.sms.project.*" %>

<%	//清除内存
	response.setHeader("Pragma","No-cache"); 
	response.setHeader("Cache-Control","no-cache"); 
	response.setDateHeader("Expires", 0); 
%> 

<%--
	project/headman/report-add.jsp
 --%>
 
<%
	request.setCharacterEncoding("utf-8");
	String userno = (String)session.getAttribute("userno");
	
	int proID = Integer.parseInt(request.getParameter("proID"));
	
	Project p = null;
	List<Project> list = new ArrayList<Project>();
	list = Task.getProject(proID);
	if(list != null && list.size() > 0) {
		p = (Project)list.get(0);
	} else {
		return;
	}
	
%>

<body>
<div id="project">
<form id="add-report" method="post" action="ReportUploadServlet" enctype="multipart/form-data" onSubmit="return checkReport();" target="addReport2_iframe">
<input type="hidden" name="fromID" id="fromID" value="<%= userno %>"/>
<input type="hidden" name="proID" id="proID" value="<%= p.getProID() %>"/>
<input type="hidden" name="level" id="level" value="<%= p.getGrade() %>"/>
<table cellpadding="0" cellspacing="0" width="500">
    <tr>
    	<td><label for="name">项目名称：</label></td>
    	<td style="text-align:left;"><%= p.getProName() %></td>
    </tr> 
     <tr>
     	<td><label for="header">汇报接收者：</label></td>
     	<td style="text-align:left;"><input id="receive" name="toID" /><!--   <input id="header" style="width:125px;" />  --></td>
     	<td id="add-file" style="color:#F00;">继续添加附件</td>  <!--返回json数据-->
   	</tr>
     <tr class="addfiles">
     	<td><label for="file">添加附件：</label></td>
     	<td style="text-align:left;"><input type="file" id="file" name="load" style="width:125px;" /></td>
     </tr> 
      <tr>
      	<td><label for="desc">描述：</label></td>
      	<td><textarea name="content" id="desc" style="width:200px; height:120px; overflow:scroll;"></textarea></td>
      </tr>
      <tr>
      	<td><label for="limit">查看权限:</label></td>
      	<td style="text-align:left;">
      		<select name="limit" id="limit">
      			<option value="all">所有人</option>
      			<option value="limit">权限范围内的人</option>
      		</select>
   		</td>
	</tr>
     <tr><td colspan="2" align="center"><input type="submit"  id="submit"  value="提交"  style="margin-top:10px;" /></td></tr>
</table>
</form>
<iframe name="addReport2_iframe" style="display:none;">
</iframe>
</div>
<script type="text/javascript">
$("#receive").combobox({
	multiple:true,//汇报接收者可以是多个人，但是只能是项目组长或者老师
	valueField:"tno", 
	 url:'GetTeacherServlet?proID=' + $('#proID').attr('value'),/*返回json数据格式的链接*///汇报接收者，判断汇报的项目是二级还是三级的，如果是三级的则只能汇报给组长，注意返回数据的差距，链接不一样
    textField:"tname"  /*！！！！后台同学注意返回json中字段的对应哈，id表示显示顺序，text字段对应的文本显示在下拉框中*/ 
	})

$("#add-file").click(function(){
	var clonefile=$(".addfiles").first().clone();
	if($(".addfiles").length<=4){
  $(".addfiles").last().after(clonefile);
	}
	else{
		alert('亲，一次性最多只能添加5个附件哦');
		}
	})

$('#deadline').datebox({
			formatter:function(date){
				return date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate();
				
				}
			})

function callback(msg)   
{   
 	//alert(msg);
 	if(msg=='ok'){                              
 		alert('回复成功');
		 $('#tt').dialog('close');
 		$('#dd').dialog({
		         title:"任务/信息交流",
				 zIndex:9001,
				width:820, height:490,
				 top:140,left:365,
				 maximizable:true,
				 cache:false,
				 resizable:true,
				href:'project/headman/report-detail.jsp?row=' + $('#row').attr('value') + '&progress=' + $('#progress').attr('value'), 
			});
 	}
 	else{
	 	alert('回复失败!');
 	}
 }
			
function checkReport() {
			var receiver = $("#receive").combobox('getValue');
			var desc = $('#desc').val();
			if (desc && receiver) {
				return true;
			} else {
				alert('请补充完整信息');
				return false;
			}
}
</script>
</body>

